package WrittenTest;

import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Read { // 自定义快速读入
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }

    String nextLine() throws IOException {
        return bf.readLine();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}

public class test9 {
    public static PrintWriter out = new PrintWriter(new BufferedWriter(
            new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    // 拼凑相应字符串得分问题
    // 算法原理：贪心
    public static void main(String[] args) throws IOException {
        int n = in.nextInt();
        // nums数组记录每轮的得分
        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            long y = in.nextLong();
            long o = in.nextLong();
            long u = in.nextLong();
            // 两种特殊情况
            if (y == 0 && o == 0 && u == 0) {
                nums[i] = 0;
                continue;
            }
            if (y == 0 && o == 2 && u == 0) {
                nums[i] = 1;
                continue;
            }
            // 原理就是确定三个字符某个字符数量的最小值，即能拼出最多的"you"
            long x1 = min(y, min(o, u)) * 2;
            // 原本的字符o减去最小值，即能拼出多少连续的"oo"
            o = o - min(y, min(o, u));
            if (o > 1) {
                nums[i] = x1 + o - 1;
            }
            // o的数量<=1是，只需记录x1的得分
            else {
                nums[i] = x1;
            }
        }
        // 枚举出每轮得分
        for (long num : nums) {
            out.println(num);
        }
        out.close();
    }
}
